<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

	<xsl:template name="mostrar-cadena">
		<input>
			<xsl:if test="//Estructura/Campo[@Id=current()/@Id]/@Solo-Lectura='1' or //Consulta/@op!='agregar'">
				<xsl:attribute name="readonly">true</xsl:attribute>
			</xsl:if>
			<xsl:attribute name="value"><xsl:value-of select="Valor" /></xsl:attribute>
			<xsl:attribute name="name"><xsl:value-of select="@Id" /></xsl:attribute>
			<xsl:attribute name="id"><xsl:value-of select="@Id" /></xsl:attribute>
			<xsl:attribute name="type">text</xsl:attribute>
		</input>
		<xsl:call-template name="requerir" />
	</xsl:template>
	
	<xsl:template name="mostrar-fecha">
		<link href="Scripts/calendario.css" type="text/css" rel="stylesheet" />
		<script type="text/javascript" src="Scripts/calendario.js"></script>
		<input>
			<xsl:attribute name="type">text</xsl:attribute>
			<xsl:attribute name="value"><xsl:value-of select="Valor" /></xsl:attribute>
			<xsl:attribute name="name"><xsl:value-of select="@Id" /></xsl:attribute>
			<xsl:attribute name="Id"><xsl:value-of select="@Id" /></xsl:attribute>
			<xsl:attribute name="readonly">true</xsl:attribute>
		</input>
		<input>
			<xsl:attribute name="type">button</xsl:attribute>
			<xsl:attribute name="value">...</xsl:attribute>
			<xsl:attribute name="name"><xsl:value-of select="concat('btn',@Id)" /></xsl:attribute>
			<xsl:attribute name="onclick"><xsl:value-of select="concat('displayDatePicker(&quot;',@Id,'&quot;);')"/></xsl:attribute>
			<xsl:if test="//Estructura/Campo[@Id=current()/@Id]/@Solo-Lectura='1' or //Consulta/@op!='agregar'">
				<xsl:attribute name="disabled">true</xsl:attribute>
			</xsl:if>
		</input>
		<xsl:call-template name="requerir" />
	</xsl:template>
	
	<xsl:template name="mostrar-entero">
		<script type="text/javascript" src="Scripts/isNumeric.js"></script>
		<input>
			<xsl:if test="//Estructura/Campo[@Id=current()/@Id]/@Solo-Lectura='1' or //Consulta/@op!='agregar'">
				<xsl:attribute name="readonly">true</xsl:attribute>
			</xsl:if>
			<xsl:attribute name="type">text</xsl:attribute>
			<xsl:attribute name="value"><xsl:value-of select="Valor" /></xsl:attribute>
			<xsl:attribute name="name"><xsl:value-of select="@Id" /></xsl:attribute>
			<xsl:attribute name="Id"><xsl:value-of select="@Id" /></xsl:attribute>
			<xsl:attribute name="onkeyup">
				esEntero(document.getElementById(<xsl:value-of select="@Id" />));
			</xsl:attribute>
		</input>
		<xsl:call-template name="requerir" />
	</xsl:template>
	
	<xsl:template name="mostrar-decimal">
		<script type="text/javascript" src="Scripts/isNumeric.js"></script>
		<input>
			<xsl:if test="//Estructura/Campo[@Id=current()/@Id]/@Solo-Lectura='1' or //Consulta/@op!='agregar'">
				<xsl:attribute name="readonly">true</xsl:attribute>
			</xsl:if>
			<xsl:attribute name="type">text</xsl:attribute>
			<xsl:attribute name="value"><xsl:value-of select="Valor" /></xsl:attribute>
			<xsl:attribute name="name"><xsl:value-of select="@Id" /></xsl:attribute>
			<xsl:attribute name="Id"><xsl:value-of select="@Id" /></xsl:attribute>
			<xsl:attribute name="onkeyup">
				esDecimal(document.getElementById(<xsl:value-of select="@Id" />));
			</xsl:attribute>
		</input>
		<xsl:call-template name="requerir" />
	</xsl:template>
	
	<xsl:template name="mostrar-encriptado">
		<input>
			<xsl:if test="//Estructura/Campo[@Id=current()/@Id]/@Solo-Lectura='1' or //Consulta/@op!='agregar'">
				<xsl:attribute name="readonly">true</xsl:attribute>
			</xsl:if>
			<xsl:attribute name="name"><xsl:value-of select="@Id" /></xsl:attribute>
			<xsl:attribute name="id"><xsl:value-of select="@Id" /></xsl:attribute>
			<xsl:attribute name="type">password</xsl:attribute>
			<xsl:attribute name="disabled">disabled</xsl:attribute>
			<xsl:attribute name="value"></xsl:attribute>
		</input>
		<input >
			<xsl:attribute name="id"><xsl:value-of select="concat('chk',@Id)" /></xsl:attribute>
			<xsl:attribute name="type">checkbox</xsl:attribute>
			<xsl:attribute name="onclick">document.getElementById('<xsl:value-of select="@Id"/>').disabled = !(document.getElementById('<xsl:value-of select="concat('chk',@Id)" />').checked);</xsl:attribute>
		</input>
	</xsl:template>
	
	<xsl:template name="mostrar-check">
		<script language="javascript" src="Scripts/checkbox.js"></script>
		<input>
			<xsl:attribute name="type">checkbox</xsl:attribute>
				<xsl:if test="//Estructura/Campo[@Id=current()/@Id]/@Solo-Lectura='1' or //Consulta/@op!='agregar'">
					<xsl:attribute name="disabled">disabled</xsl:attribute>
				</xsl:if>
			<xsl:if test="Valor = 1">
				<xsl:attribute name="checked">checked</xsl:attribute>
			</xsl:if>
			<xsl:attribute name="name">boolChk<xsl:value-of select="@Id" /></xsl:attribute>
			<xsl:attribute name="Id">boolChk<xsl:value-of select="@Id" /></xsl:attribute>
			<xsl:attribute name="onclick">
				obtValor(document.getElementById('boolChk<xsl:value-of select="@Id" />'), document.getElementById('<xsl:value-of select="@Id" />'));
			</xsl:attribute>
		</input>
		<input>	
			<xsl:attribute name="value"><xsl:value-of select="Valor" /></xsl:attribute>
			<xsl:attribute name="name"><xsl:value-of select="@Id" /></xsl:attribute>
			<xsl:attribute name="id"><xsl:value-of select="@Id" /></xsl:attribute>
			<xsl:attribute name="type">hidden</xsl:attribute>
		</input>
	</xsl:template>
	
	<xsl:template name="busca-select">
		<xsl:if test="string-length(//Estructura/Campo[@Id=current()/@Id]/@Sel)>0">
			 <br />(...) 
			 <input type="text">
				<xsl:attribute name="id"><xsl:value-of select="concat('txtb', @Id)" /></xsl:attribute>
				<xsl:attribute name="name"><xsl:value-of select="concat('txtb', @Id)" /></xsl:attribute>
				<xsl:attribute name="onkeyup">searchSel(document.getElementById('<xsl:value-of select="concat('txtb', @Id)" />'), document.getElementById('<xsl:value-of select="@Id" />'));</xsl:attribute>
			</input>
		</xsl:if>
	</xsl:template>
	
	<xsl:template name="combo">
		<xsl:param name="valor"/>
		<xsl:param name="consulta" />
		<script language="javascript1.2" src="../Interfaz/Scripts/busca-combo.js"></script>
		<select>
			<xsl:attribute name="name"><xsl:value-of select="@Id" /></xsl:attribute>
			<xsl:attribute name="id"><xsl:value-of select="@Id" /></xsl:attribute>
			<xsl:if test="//Estructura/Campo[@Id=current()/@Id]/@Solo-Lectura='1' or //Consulta/@op!='agregar'">
				<xsl:attribute name="disabled">true</xsl:attribute>
			</xsl:if>
			<xsl:for-each select="$consulta/Fila">
				<option>
					<xsl:attribute name="value"><xsl:value-of select="@Id"/></xsl:attribute>
					<xsl:if test="$valor=current()/Columna">
						<xsl:attribute name="selected">selected</xsl:attribute>
					</xsl:if>
					<xsl:value-of select="Columna"></xsl:value-of>
				</option>
			</xsl:for-each>
		</select>
	</xsl:template>
	
	<xsl:template name="es-requerido">
		<xsl:choose>
			<xsl:when test="//Estructura/Campo[@Id=current()/@Id]/@Anulable='0'">
				*
			</xsl:when>
		</xsl:choose>
	</xsl:template>
	
	<xsl:template name="requerir">
		<xsl:if test="//Consulta[@Nombre='Giras']/Estructura/Campo[@Id=current()/@Id]/@Solo-Lectura='0' and //Consulta[@Nombre='Giras']/@op!='borrar' and //Consulta[@Nombre='Giras']/@op!='negar'">
		<xsl:if test="//Consulta[@Nombre='Giras']/Estructura/Campo[@Id=current()/@Id]/@Anulable='0'">
			<script>requerido('<xsl:value-of select="@Id" />', 
			'<xsl:choose>
				<xsl:when test="string-length(//Consulta[@Nombre='Giras']/Estructura/Campo[@Id=current()/@Id]/@Alias)>0">
					<xsl:value-of select='//Estructura/Campo[@Id=current()/@Id]/@Alias' />
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of select="//Consulta[@Nombre='Giras']/Estructura/Campo[@Id=current()/@Id]/@Nombre" />
				</xsl:otherwise>
			</xsl:choose>');</script>
		</xsl:if>	
		</xsl:if>
	</xsl:template>

</xsl:stylesheet>